package com.kaifamiao.context;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter( urlPatterns = "/*" , dispatcherTypes = { DispatcherType.REQUEST,DispatcherType.FORWARD,DispatcherType.INCLUDE})
public class CharacterEncodingFilter implements Filter {

    @Override
    public void doFilter(ServletRequest req , ServletResponse resp, FilterChain chain)
            throws IOException, ServletException {
        req.setCharacterEncoding( "UTF-8" );
        resp.setCharacterEncoding( "UTF-8" );
        chain.doFilter( req , resp );
    }

}
